CXXFLAGS := -std=c++11                      \
            -fdiagnostics-color=always      \
            -Wl,--copy-dt-needed-entries    \
            -g

ASCEND_DIR = /usr/local/Ascend/ascend-toolkit/latest

HCCL_INC_DIR = ${ASCEND_DIR}/include
HCCL_LIB_DIR = ${ASCEND_DIR}/lib64

ACL_INC_DIR = ${ASCEND_DIR}/include
ACL_LIB_DIR = ${ASCEND_DIR}/lib64

LIBS = -L$(HCCL_LIB_DIR) -lhccl    \
       -L$(ACL_LIB_DIR)  -lascendcl

INCLUDEDIRS = -I./src                \
            -I$(HCCL_INC_DIR)      \
            -I$(ACL_INC_DIR)

all:
	@mkdir -p ./bin
	g++ $(CXXFLAGS) src/d2h.cc -o ./bin/d2h $(INCLUDEDIRS) $(LIBS)
	g++ $(CXXFLAGS) src/h2d.cc -o ./bin/h2d $(INCLUDEDIRS) $(LIBS)
	g++ $(CXXFLAGS) src/hbm.cc -o ./bin/hbm $(INCLUDEDIRS) $(LIBS)
	g++ $(CXXFLAGS) src/hccl_allreduce.cc -o ./bin/hccl_allreduce $(INCLUDEDIRS) $(LIBS)

.PHONY: clean
clean:
	rm -rf ../bin/*